﻿using System.Windows.Media;

namespace Leow.TextEditor
{
    /// <summary>
    /// Represents a set of text formatting instructions to be applied on a
    /// character-by-character basis.
    /// </summary>
    public struct CharacterBasedTextFormat : ITextFormat
    {
        private readonly Brush _brush;
        private readonly int _charStartIndex;
        private readonly int _count;
        private readonly TextFormatMode _mode;

        /// <summary>
        /// Initializes a new instance of the <c>CharacterBasedTextFormat</c>
        /// class.
        /// </summary>
        /// <param name="mode">The text formatting mode.</param>
        /// <param name="brush">The brush used in drawing the text.</param>
        /// <param name="charStartIndex">The index of the first character on
        /// which this text formatting will be applied to.</param>
        /// <param name="count">The number of characters, counted from the
        /// starting index, on which this text formatting will be applied to.
        /// </param>
        public CharacterBasedTextFormat(
            TextFormatMode mode,
            Brush brush,
            int charStartIndex,
            int count)
        {
            _mode = mode;
            _brush = brush;
            _charStartIndex = charStartIndex;
            _count = count;
        }

        /// <summary>
        /// Gets the brush used in drawing the text.
        /// </summary>
        public Brush Brush
        {
            get
            {
                return _brush;
            }
        }

        /// <summary>
        /// Gets the index of the first character on which this text formatting
        /// will be applied to.
        /// </summary>
        public int CharStartIndex
        {
            get
            {
                return _charStartIndex;
            }
        }

        /// <summary>
        /// Gets the number of characters, counted from the starting index, on
        /// which this text formatting will be applied to.
        /// </summary>
        public int Count
        {
            get
            {
                return _count;
            }
        }

        /// <summary>
        /// Gets the text formatting mode.
        /// </summary>
        public TextFormatMode Mode
        {
            get
            {
                return _mode;
            }
        }
    }
}
